package proj.reseau;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.math.BigInteger;
import java.security.MessageDigest;

public class MD5 {
	public static String encode(String path) throws Exception {
		MessageDigest md = MessageDigest.getInstance("MD5");
	    BufferedInputStream in = new BufferedInputStream(new FileInputStream(path));

	    int theByte = 0;
	    while ((theByte = in.read()) != -1) {
	      md.update((byte) theByte);
	    }
	    in.close();
	    
	    return (new BigInteger(1, md.digest()).toString(16));
	}
}

